<?php
$smarty->configLoad($lang . '/banlist.module.php');
$language = parse_ini_file($lang . '/breadcrumb.module.php', true);
$breadcrumb = $language['add_banlist'];

if(isset($_GET['username'])) {
	$user = $_GET['username'];
} else {
	$user = '';
}
if(isset($_GET['reason'])) {
	$reason = $_GET['reason'];
} else {
	$reason = '';
}
$smarty->assign('user', $user);
$smarty->assign('reason', $reason);
$user = new user;
if(isset($_POST['submit'])) {
	
	$sql = 'UPDATE SET '.DB_LOGIN.'.account_data SET activated = 0 WHERE name LIKE :name';
	$dbh = $connection->prepare($sql);
	$dbh->bindValue(':name', $_POST['username_banned']);
	$dbh->execute();
	$userID = $user->getID($_POST['username_banned']);
	
	$sql = 'INSERT INTO '.DB_CMS.'.module_banlist (timestamp, userID, reason) VALUES (CURRENT_TIMESTAMP, :userID, :reason)';
	$dbh = $connection->prepare($sql);
	$dbh->bindValue(':userID', $userID);
	$dbh->bindValue(':reason', $_POST['message']);
	$dbh->execute();
	
	
	$sql = 'DELETE FROM '.DB_CMS.'.module_creport WHERE userID = :userID';
	$dbh = $connection->prepare($sql);
	$dbh->bindValue(':userID', $userID);
	$dbh->execute();
	$main->jqmodal('addet');
	echo '<meta http-equiv="refresh" content="5; URL=index.php?mod=banlist">';
	
}
$template = 'banlist/add.tpl';
?>
